home *** CD-ROM | disk | FTP | other *** search
Wrap
VERSION 2.00 Begin Form Form1 Caption = "Form1" ClientHeight = 4035 ClientLeft = 1905 ClientTop = 2055 ClientWidth = 4365 Height = 4440 Left = 1845 LinkTopic = "Form1" ScaleHeight = 4035 ScaleWidth = 4365 Top = 1710 Width = 4485 Begin TextBox txtPWD2 Height = 285 Left = 2640 PasswordChar = "#" TabIndex = 12 Text = "bob" Top = 1680 Width = 1335 End Begin TextBox txtUID2 Height = 285 Left = 2640 TabIndex = 11 Text = "Bob" Top = 960 Width = 1335 End Begin TextBox txtPWD1 Height = 285 Left = 360 PasswordChar = "#" TabIndex = 7 Text = "mary" Top = 1680 Width = 1335 End Begin TextBox txtUID1 Height = 285 Left = 360 TabIndex = 6 Text = "Mary" Top = 960 Width = 1335 End Begin CommandButton Command2 Caption = "Open Db2" Height = 495 Left = 2640 TabIndex = 3 Top = 3120 Width = 1215 End Begin CommandButton Command1 Caption = "Open Db" Height = 495 Left = 360 TabIndex = 2 Top = 3120 Width = 1215 End Begin TextBox Text2 DataSource = "Data2" Height = 285 Left = 2640 TabIndex = 1 Top = 2280 Width = 1215 End Begin TextBox Text1 DataSource = "Data1" Height = 285 Left = 360 TabIndex = 0 Top = 2280 Width = 1215 End Begin Data Data2 Caption = "Data2" Connect = "" DatabaseName = "" Exclusive = 0 'False Height = 270 Left = 2640 Options = 0 ReadOnly = 0 'False RecordSource = "" Top = 2760 Width = 1140 End Begin Data Data1 Caption = "Data1" Connect = "" DatabaseName = "" Exclusive = 0 'False Height = 270 Left = 360 Options = 0 ReadOnly = 0 'False RecordSource = "" Top = 2760 Width = 1140 End Begin Label Label6 Caption = "Password" Height = 255 Left = 2640 TabIndex = 13 Top = 1440 Width = 1215 End Begin Label Label5 Caption = "User Name" Height = 255 Left = 2640 TabIndex = 10 Top = 720 Width = 1215 End Begin Label Label4 Caption = "Password" Height = 255 Left = 360 TabIndex = 9 Top = 1440 Width = 1215 End Begin Label Label3 Caption = "User Name" Height = 255 Left = 360 TabIndex = 8 Top = 720 Width = 1215 End Begin Label Label2 Caption = "Label2" Height = 255 Left = 2640 TabIndex = 5 Top = 240 Width = 1695 End Begin Label Label1 Caption = "Label1" Height = 255 Left = 360 TabIndex = 4 Top = 240 Width = 1695 End Option Explicit Dim dbname1 As String Dim dbname2 As String Dim myPath As String 'WritePrivateProfileString Declare Function WritePrivateProfileString Lib "Kernel" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpString As String, ByVal lplFileName As String) As Integer Sub Command1_Click () On Error GoTo ErrPermissions2 SetDefaultWorkspace txtUID1.Text, txtPWD1.Text data1.DatabaseName = myPath & dbname1 data1.RecordSource = "tblStates" text1.DataField = "sState_cd" data1.Refresh Exit Sub ErrPermissions2: Select Case Err Case 3033 MsgBox "You do not have permission to this database" Exit Sub Case 3029 MsgBox Error$ Exit Sub Case Else MsgBox "An unexpected error has occurred!" & Chr(10) & Err & Chr(10) & Error$ End End Select End Sub Sub Command2_Click () On Error GoTo ErrPermissions SetDefaultWorkspace txtUID2.Text, txtPWD2.Text data2.DatabaseName = myPath & dbname2 data2.RecordSource = "tblStates" text2.DataField = "szState_nm" data2.Refresh Exit Sub ErrPermissions: Select Case Err Case 3033 MsgBox "You do not have permission to this database" Exit Sub Case 3029 MsgBox Error$ Exit Sub Case Else MsgBox "An unexpected error has occurred!" & Chr(10) & Err & Chr(10) & Error$ End End Select End Sub Sub Form_Load () Dim MDA As String Dim rc As Integer Dim INInm As String myPath = APP.Path & IIf(Right$(APP.Path, 1) = "\", "", "\") 'INInm = myPath & APP.EXEName & ".ini" INInm = "C:\aaamarch\msu\vbmsu\example\security\security.INI" MDA = myPath & "System.MDA" rc = WritePrivateProfileString("Options", "Systemdb", MDA, myPath & INInm) SetDataAccessOption 1, INInm dbname1 = "MARY.MDB" dbname2 = "BOB.MDB" label1.Caption = dbname1 label2.Caption = dbname2 End Sub